{template 'public/header'}

{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <!--<li class="active"><a >用户列表</a></li>-->
    <li  {if $type=='all'} class="active" {/if}><a href="{php echo $this->createWebUrl('user',array('type'=>all));}">全部用户</a></li>
    <li   {if $type=='adminlist'} class="active" {/if}><a href="{php echo $this->createWebUrl('user',array('type'=>adminlist));}">管理员列表</a></li>

</ul>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="user" />
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入客户名称">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </div>
</div>
<div class="main">
    <div class="panel panel-default">
        <div class="panel-heading">
            用户列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <td class="store_td1 col-md-1">用户id</td>
                        <td class="col-md-1">头像</td>
                        <td class="col-md-1">用户名</td>
                        <td class="col-md-1">手机号</td>
                        <td class="col-md-1">openid</td>
                        <td class="col-md-1">可用积分/总积分</td>
                        <td class="col-md-1">租车券数量</td>
                        <td class="col-md-1">优惠券数量</td>
                        <td class="col-md-1">存入时间</td>
                        <td class="col-md-1">是否管理员</td>
                        <td class="col-md-2">操作</td>
                    </tr>
                    {loop $list $key $item}
                    <tr class="yg5_tr2">
                        <td>{$item['id']}</td>
                        <td>
                            <img src="{$item['headimg']}" style="width: 50px;">
                        </td>
                        <td>{$item['user_name']}</td>
                        <td>{$item['user_tel']}</td>
                        <td>{$item['openid']}</td>
                        <td>{$item['now_integral']}/{$item['all_integral']}</td>
                        <td>{$item['rent']}</td>
                        <td>{$item['coupon']}</td>
                        <td>{$item['time']}</td>
                        {if $item['isadmin']==0}
                        <td>否</td>
                        {elseif $item['isadmin']==1}
                        <td>是</td>
                        {/if}
                        <td>
                            <a href="{php echo $this->createWebUrl('user_id_card_info',array('uid'=>$item['id']));}"><button class="btn btn-success btn-xs">查看身份信息</button></a>
                            <a href="{php echo $this->createWebUrl('user_id_card_info',array('uid'=>$item['id']));}"><button class="btn btn-success btn-xs">查看身份信息</button></a>
                            {if $item['isadmin']==1}
                            <a href="{php echo $this->createWebUrl('user',array('op'=>'qxadmin','id'=>$item['id']));}"><button class="btn storeblue btn-xs">取消管理员</button></a>
                            {elseif $item['isadmin']==0}
                            <a href="{php echo $this->createWebUrl('user',array('op'=>'admin','id'=>$item['id']));}"><button class="btn storeblue  btn-xs">设为管理员</button></a>
                            {/if}
                            <!--<a href="{php echo $this->createWebUrl('record',array('uid'=>$item['id']));}"><button class="btn btn-success btn-xs">查看积分明细</button></a>
-->
                            <a href="{php echo $this->createWebUrl('coupondetails',array('uid'=>$item['id'],'type'=>2));}"><button  class="btn btn-danger btn-xs">查看优惠券明细</button></a>
                         <!--   <a href="{php echo $this->createWebUrl('coupondetails',array('uid'=>$item['id'],'type'=>1));}"><button class="btn btn-default btn-xs">查看租车券明细</button></a>-->
                        </td>
                    </tr>

                    {/loop}
                    {if empty($list)}
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无用户信息
                        </td>
                    </tr>
                    {/if}
                </table>
            </div>
        </div>
    </div>
</div>
<div class="text-right we7-margin-top">
    {$pager}
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-11").show();
        $("#yframe-11").addClass("wyactive");
        // ———————————————批量删除———————————————
        $("#allselect").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要删除的商品!');
                return false;
            }else if(confirm("确认要删除此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });

                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Deleteuser&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })

            }
        });

        // ———————————————批量通过———————————————
        $("#allpass").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要通过的商品!');
                return false;
            }else if(confirm("确认要通过此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Adoptuser&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        // ———————————————批量拒绝———————————————
        $("#allrefuse").on('click',function(){
            var check = $("input[type=checkbox][class!=allcheck]:checked");
            if(check.length < 1){
                alert('请选择要拒绝的商品!');
                return false;
            }else if(confirm("确认要拒绝此商品?")){
                var id = new Array();
                check.each(function(i){
                    id[i] = $(this).val();
                });
                console.log(id)
                $.ajax({
                    type:"post",
                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=Rejectuser&m=yzzc_sun",
                    dataType:"text",
                    data:{id:id},
                    success:function(data){
                        console.log(data);
                        location.reload();
                    }
                })
            }
        });

        $(".allcheck").on('click',function(){
            var checked = $(this).get(0).checked;
            $("input[type=checkbox]").prop("checked",checked);
        });
    })
</script>